//
//  NAImageView.m
//  NewApp
//
//  Created by  on 12-6-15.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "NAImageView.h"

@interface NAImageView (Private) 

/**
 *  Shows image
 */
- (void) showImage:(UIImage *) image;

///**
// *  Image view did pressed
// */
//- (void) imageDidPressed:(id) sender;

@end

@implementation NAImageView
@synthesize naImage;//,delegate;

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.alpha = 0.f;
//        [self addTarget:self action:@selector(imageDidPressed:) 
//       forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

- (void) dealloc {
    [naImage release];
    [super dealloc];
}

#pragma mark - 
#pragma mark - Private methods


- (void) showImage:(UIImage *) image {
    [self setBackgroundImage:image forState:UIControlStateNormal];
    
    [UIView animateWithDuration:1.f
                     animations:^{
                         
                         self.alpha = 1.0f;
                     } completion:^(BOOL finished) {
                         //self.alpha = 1.0f;
                     }];
}

//- (void) imageDidPressed:(id) sender {
//    if (self.delegate != nil) {
//        if ([self.delegate respondsToSelector:@selector(NAImageViewDidPressedWithNAImage:)]) {
//            [self.delegate NAImageViewDidPressedWithNAImage:self.naImage];
//        }
//    }
//}

#pragma mark -
#pragma mark - Imageloading delegate

- (void)didLoadImage:(NSURL *)imageURL Image:(UIImage *)image {
    [self performSelectorOnMainThread:@selector(showImage:) withObject:image waitUntilDone:NO];
}

@end
